package com.inforich.web.controller.unsignwarning;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.inforich.common.annotation.Log;
import com.inforich.common.core.controller.BaseController;
import com.inforich.common.enums.BusinessType;
import com.inforich.common.utils.poi.ExcelUtil;
import com.inforich.unsignwarning.domain.RubbishUnsignWarning;
import com.inforich.unsignwarning.domain.RubbishUnsignWarningCell;
import com.inforich.unsignwarning.service.IRubbishUnsignWarningService;

/**
 * 未打卡预警Controller
 *
 * @author liujie
 * @date 2022-11-29
 */
@RestController
@RequestMapping("/report/unsignwarning")
public class RubbishUnsignWarningController extends BaseController {

  @Autowired
  private IRubbishUnsignWarningService rubbishUnsignWarningService;

  /**
   * 查询未打卡预警列表
   */
  @PreAuthorize("@ss.hasPermi('report:unsignwarning:list')")
  @GetMapping("/list")
  public Page<RubbishUnsignWarningCell> list(Page<RubbishUnsignWarningCell> page,
      RubbishUnsignWarning rubbishUnsignWarning) {
    Map<String, Object> map = beanToMap(rubbishUnsignWarning);
    rubbishUnsignWarningService.pageRubbishUnsignWarningCell(page, map);
    return page;
  }

  /**
   * 导出未打卡预警列表
   */
  @PreAuthorize("@ss.hasPermi('report:unsignwarning:export')")
  @Log(title = "未打卡预警", businessType = BusinessType.EXPORT)
  @PostMapping("/export")
  public void export(HttpServletResponse response, RubbishUnsignWarning rubbishUnsignWarning) {
    Map<String, Object> map = beanToMap(rubbishUnsignWarning);
    List<RubbishUnsignWarningCell> list = rubbishUnsignWarningService.listRubbishUnsignWarningCell(
        map);
    ExcelUtil<RubbishUnsignWarningCell> util =
        new ExcelUtil<RubbishUnsignWarningCell>(RubbishUnsignWarningCell.class);
    util.exportExcel(response, list, "未打卡预警");
  }
}
